package com.vote.controller;

import com.vote.repository.GirlRepository;
import com.vote.entity.Girl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by PC-liuwei on 2017/5/8.
 */
@RestController
public class GirlController {
    @Autowired
    private GirlRepository girlRepository;

    @GetMapping(value = "/girlList")
    public List<Girl> girlList(){
        return girlRepository.findAll();
    }

    @PostMapping(value="/girlAdd")
    public Girl girlAdd(@RequestParam("age") Integer age,@RequestParam("cupSize") String cupSize){
        Girl girl = new Girl();
        girl.setAge(age);
        girl.setCupSize(cupSize);
        return girlRepository.save(girl);
    }
}
